//
//  OMHTTPRequest.h
//  RequestTest
//
//  Created by xntech on 13-8-19.
//  Copyright (c) 2013年 xntech. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "ASIFormDataRequest.h"
#import "OMURL.h"
#import "OMBody.h"
@class OMHTTPRequest;
typedef void (^RequestCancel)(OMHTTPRequest *);
typedef void (^RequestFinish)(OMHTTPRequest *);
typedef void (^RequestStart)(OMHTTPRequest *);
typedef void (^RequestFailed)(OMHTTPRequest *);
typedef void (^RequestReveiveHeader)(OMHTTPRequest *,NSDictionary *);
@interface OMHTTPRequest : NSObject
{
    NSString   *_method;
    NSMutableDictionary  *_userInfo;
    OMURL   *_url;
    ASIHTTPRequest  *_internalRequest;
    OMBody    *_body;
    BOOL   _showLoadingHub;
    BOOL   _showFailedHub;
    BOOL   _showErrorHub;
}
@property (nonatomic,retain)OMURL  *url;
@property (nonatomic,copy)NSString  *method;
@property (nonatomic,assign)float timeoutSeconds;
@property (nonatomic,assign)BOOL showLoadingHub;
@property (nonatomic,assign)BOOL showFailedHub;
@property (nonatomic,assign)BOOL showErrorHub;


@property (nonatomic,copy)RequestCancel cancelBlock;
@property (nonatomic,copy)RequestFinish finishBlock;
@property (nonatomic,copy)RequestStart  startBlock;
@property (nonatomic,copy)RequestFailed failedBlock;
@property (nonatomic,copy)RequestReveiveHeader headerBlock;
@property (nonatomic,retain)OMBody *body;


- (id)initWithOMURL:(OMURL *)url;

- (void)setUserInfoValue:(id)value forKey:(id)key;
- (id)userInfoValueForKey:(id)key;

- (void)startAsynchronous;
- (void)startSynchronous;

- (void)startAsynchronous:(float)startInterval;
- (void)startSynchronous:(float)startInterval;
- (void)cancel;

- (NSString *)responseString;
- (NSData *)responseData;
- (NSDictionary *)responseHeader;
- (int)responseCode;
- (NSString *)responseMessage;
- (NSArray *)responseCookies;
- (BOOL)isExecuting;
- (BOOL)isFinished;
- (BOOL)isCancelled;

@end
